<%@ page language="java" import="java.util.*,cn.biwysh.exam.entity.Category" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
List<Category> list=null;
List<Category> userlist=null;
if(request.getAttribute("list")!=null){
	list=(List<Category>)request.getAttribute("list");
}
if(request.getAttribute("userlist")!=null){
	userlist=(List<Category>)request.getAttribute("userlist");
}
String ok="";
if(request.getAttribute("ok")!=null){
	ok=request.getAttribute("ok").toString();
}

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>自定义知识库</title>
    <link href="css/qt/zdyzsk.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="script/jquery/jquery-1.5.1.min.js">
        </script>
    <script type="text/javascript">
    var myArray=new Array();
    <%if(userlist!=null){
      for(int i=0;i<userlist.size();i++){
    %>
    	myArray[<%=i%>]=<%=userlist.get(i).getId()%>;
    <%}
      }%>
$(function() {
    if(!window.ActiveXObject){
        $("#footht").css("height","20px");
    }
    initZYbg();
    initUserData();
    <%if(ok.length()>0){%>
    	alert("保存成功！");
    <%}%>
	$(window).resize(function() {
			    initZYbg();
			   });
	    });
function initZYbg(){ 
	//alert($(document).width());
      if(document.body.clientWidth<957){
	        $("#mainleft").width(0);
	        $("#mainright").width(0);
	        $("#mainleft").css("display","none");
		    $("#mainright").css("display","none");
        }else{
	       if(!window.ActiveXObject){
		        var wid=($(document).width()-953)/2;
		        $("#mainleft").width(wid);
		        $("#mainright").width(wid);
		        $("#mainleft").css("display","block");
		        $("#mainright").css("display","block");
		    }else{
		        var wid=($(document).width()-974)/2;
		        if(wid>0){
		        	$("#mainleft").width(wid);
			        $("#mainright").width(wid);
			        $("#mainleft").css("display","block");
			        $("#mainright").css("display","block");
		        }
		    }
        }
}
function chengeFocus(id){
	var state=$("#duihao_"+id).attr("state");
	if(state=="0"){
		$("#duihao_"+id).attr("state","1");
		$("#duihao_"+id).removeClass("duihaooff").addClass("duihaoon");
		$("#cate_"+id).removeClass("cateoff").addClass("cateon");
		$("#catename_"+id).removeClass("catenameoff").addClass("catenameon");
	}else{
		$("#duihao_"+id).attr("state","0");
		$("#duihao_"+id).removeClass("duihaoon").addClass("duihaooff");
		$("#cate_"+id).removeClass("cateon").addClass("cateoff");
		$("#catename_"+id).removeClass("catenameon").addClass("catenameoff");
	}
}
function initUserData(){
	for(var i=0;i<myArray.length;i++){
		$("#duihao_"+myArray[i]).attr("state","1");
		$("#duihao_"+myArray[i]).removeClass("duihaooff").addClass("duihaoon");
		$("#cate_"+myArray[i]).removeClass("cateoff").addClass("cateon");
		$("#catename_"+myArray[i]).removeClass("catenameoff").addClass("catenameon");
	}
}
function sumbitData(){
	var temp="#";
	$(".duihaoon").each(function(){
		temp=temp+$(this).attr("ids")+"#";
	});
	$("#ids").val(temp);
	if(temp.length<2){
		alert("请选择分类");
		return false;
	}
	$("#updateform").submit();
}
    </script>
  </head>
  
  <body>
    <div id="mainleft"><img src="img/qt/mainleft.jpg" style="width:100%;height:100%;"/></div>
     <div id="main">
      <div id="top">
            <jsp:include page="title.jsp" flush="true">
             <jsp:param name="jspName" value="zdyzsk" />
           </jsp:include>
           <div class="clear">
           </div>
       </div>
       <div id="tgTXT">
           <div id="tiao" ></div>
           <div id="mainbg">
             <div id="listshow">
               <%if(list!=null){
                  for(int i=0;i<list.size();i++){%>
	               <div id="cate_<%=list.get(i).getId() %>" class="cate cateoff">
	                 <div id="duihao_<%=list.get(i).getId() %>" class="duihao duihaooff" state="0" ids="<%=list.get(i).getId() %>" onclick="chengeFocus(<%=list.get(i).getId() %>)"></div>
	                 <span id="catename_<%=list.get(i).getId() %>" class="catename catenameoff"><%=list.get(i).getName() %></span>
	               </div>
               <% }
                  if(list.size()==0){%>
                	  目前还没有分类！
                <%  }
                 } %>
             </div>
             <div id="dotline" style="height: 30px; width:95%; float:left; margin-left:20px; border-bottom:dotted 1px #9E9E9E;clear:both;"></div>
             <div style="clear:both;padding-top:15px; "><img style="cursor:pointer;" onclick="sumbitData()" src="img/qt/save.jpg"/></div>
           </div>
           <div id="mainbottom"></div>
       </div>
      <form id="updateform" name="updateform" method="post" action="zdyzsk.do">
        <input id="ids" name="ids" type="hidden" value=""/>
      </form>
      <div id="footht" style=""></div>
      <div id="footer">
		  <jsp:include page="footer.jsp" flush="true"></jsp:include>
	   </div>
     </div>
     <div id="mainright"><img src="img/qt/mainright.jpg" style="width:100%;height:100%;"/></div>
  </body>
   <SCRIPT LANGUAGE="JavaScript">   
		<!--   
	     //下面兼容ie6
	     var isIE = !!window.ActiveXObject;  
		 var isIE6 = isIE && !window.XMLHttpRequest; 
		 if (isIE6) {  
	      $("#dotline").css("margin-left","10px");
	      $(".cate").css("margin-left","18px");
	    } 
		
		//-->   
</SCRIPT>
</html>
